/* 
 * File:   Dust.h
 * Author: Filipp
 *
 * Created on July 16, 2010, 5:39 PM
 */

#ifndef _DUST_H
#define	_DUST_H


#include "misc.h"
#include "Flob.h"


class Particle;

class DustPan{
public:
	DustPan(vec2i s, Flob* mf);
	~DustPan();

	void resize(vec2i s);

	void step(float dt);
	void draw();

	vec2i getSize() const;
private:
	inline size_t IX(int x, int y);
	inline size_t IX(vec2i xy);
	vec2i sizexy;
	size_t size;

	Flob* myFlob;

	Particle** field;	//NULL if empty
};

size_t DustPan::IX(int x, int y){
	return sizexy.x*y+x;
}
size_t DustPan::IX(vec2i xy){
	return sizexy.x*xy.y+xy.x;
}

class Particle{
public:
	friend class DustPan;
	Particle(DustPan* dp, float m=1, vec2f cp=vec2f(), vec2f op=vec2f());
	vec2f step(float dt);	//returns distance moved

	void applyForce(vec2f force);
	void applyAcc(vec2f acc);

	vec2f currentPosition;
	vec2f oldPosition;
	vec2f acceleration;
	float mass;
	DustPan* myPan;
};





#endif	/* _DUST_H */




